import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import axios from 'axios'
export default function Cateagory() {
    // let [count, setCount] = useState(0)
    // let [arr, setArr] = useState([1, 2, 3])
    // let [obj, setObj] = useState({ uname: '张三' })
    var params = useParams()
    var [arr, setArr] = useState({})
    // function add() {
    //     count++
    //     setCount(count)
    // }
    // function push() {
    //     // arr.push(4)
    //     setArr([...arr, 4])
    // }
    // function uname() {
    //     obj.uname = '李四'
    //     setObj({ ...obj })
    // }
    useEffect(() => {
        axios
            .get(
                `https://apipc-xiaotuxian-front.itheima.net/category?id=${params.id}`
            )
            .then(res => {
                if (res.data.msg == '操作成功') {
                    arr = res.data.result.children
                    setArr({ ...arr })
                    console.log(arr);
                }
            });
    }, [params.id])
    return <div>
        {/* <p onClick={add}>{count}</p>
        <p onClick={push}>{arr}</p>
        <p onClick={uname}>{obj.uname}</p> */}
    </div>
}
